package com.itwn.comic.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itwn.comic.entity.Tag;
import com.itwn.comic.mapper.TagMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TagService {
    @Autowired
    TagMapper tagMapper;

    public PageInfo<Tag> queryTagByName(Integer now, Integer size, String name) {
        PageHelper.startPage(now,size);
        List<Tag> list=tagMapper.selectByName(name);
        return new PageInfo<>(list);
    }

    public void modifyTag(Tag tag) {
        tagMapper.updateByPrimaryKey(tag);
    }

    public void addTag(Tag tag) {
        tagMapper.insert(tag);
    }

    public void delTag(int id) {
        tagMapper.deleteByPrimaryKey(id);
    }

    public List<Tag> queryAll() {
        return this.tagMapper.selectAll();
    }
}
